package com.homelock.service.sms;

import com.homelock.common.enums.sms.KeYinSmsTemplateEnum;
import com.homelock.common.enums.sms.SmsSendTypeEnum;
import com.homelock.common.enums.sms.ZxSmsTemplateEnum;
import com.pi.base.exception.ServiceException;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author chenmf@163.com
 * @date 2020年07月15日02:36:00
 */
@Service("smsTemplateService")
public class SmsTemplateService {

    private static final Long ZHEN_XIN_SOURCE_ID = 107521909721137152L;

    private static final String SIGN_KY = "科银管家";

    private static final String SIGN_ZX = "振兴云锁";

    public String getSmsTemplateBySource(SmsSendTypeEnum smsSendTypeEnum, Long sourceId) {
        if (ZHEN_XIN_SOURCE_ID.equals(sourceId)) {
            return Optional.ofNullable(ZxSmsTemplateEnum.getBySmsSendType(smsSendTypeEnum))
                    .orElseThrow(() -> new ServiceException("SMS_TEMPLATE_NOT_FOUND"));
        }
        return Optional.ofNullable(KeYinSmsTemplateEnum.getBySmsSendType(smsSendTypeEnum))
                .orElseThrow(() -> new ServiceException("SMS_TEMPLATE_NOT_FOUND"));
    }

    public String getSignBySource(Long sourceId) {
        if (ZHEN_XIN_SOURCE_ID.equals(sourceId)) {
            return SIGN_ZX;
        }
        return SIGN_KY;
    }
}
